package com.ruralflow.flow.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruralflow.common.annotation.Log;
import com.ruralflow.common.core.controller.BaseController;
import com.ruralflow.common.core.domain.AjaxResult;
import com.ruralflow.common.enums.BusinessType;
import com.ruralflow.flow.domain.FlowPass;
import com.ruralflow.flow.service.IFlowPassService;
import com.ruralflow.common.utils.poi.ExcelUtil;
import com.ruralflow.common.core.page.TableDataInfo;

/**
 * 通行证概览Controller
 * 
 * @author ruralflow
 * @date 2025-02-20
 */
@RestController
@RequestMapping("/flow/flowPass")
public class FlowPassController extends BaseController
{
    @Autowired
    private IFlowPassService flowPassService;

    /**
     * 查询通行证概览列表
     */
    @PreAuthorize("@ss.hasPermi('flow:flowPass:list')")
    @GetMapping("/list")
    public TableDataInfo list(FlowPass flowPass)
    {
        startPage();
        List<FlowPass> list = flowPassService.selectFlowPassList(flowPass);
        return getDataTable(list);
    }

    /**
     * 导出通行证概览列表
     */
    @PreAuthorize("@ss.hasPermi('flow:flowPass:export')")
    @Log(title = "通行证概览", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FlowPass flowPass)
    {
        List<FlowPass> list = flowPassService.selectFlowPassList(flowPass);
        ExcelUtil<FlowPass> util = new ExcelUtil<FlowPass>(FlowPass.class);
        util.exportExcel(response, list, "通行证概览数据");
    }

    /**
     * 获取通行证概览详细信息
     */
    @PreAuthorize("@ss.hasPermi('flow:flowPass:query')")
    @GetMapping(value = "/{passId}")
    public AjaxResult getInfo(@PathVariable("passId") Long passId)
    {
        return success(flowPassService.selectFlowPassByPassId(passId));
    }

    /**
     * 新增通行证概览
     */
    @PreAuthorize("@ss.hasPermi('flow:flowPass:add')")
    @Log(title = "通行证概览", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FlowPass flowPass)
    {
        return toAjax(flowPassService.insertFlowPass(flowPass));
    }

    /**
     * 修改通行证概览
     */
    @PreAuthorize("@ss.hasPermi('flow:flowPass:edit')")
    @Log(title = "通行证概览", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FlowPass flowPass)
    {
        return toAjax(flowPassService.updateFlowPass(flowPass));
    }

    /**
     * 删除通行证概览
     */
    @PreAuthorize("@ss.hasPermi('flow:flowPass:remove')")
    @Log(title = "通行证概览", businessType = BusinessType.DELETE)
	@DeleteMapping("/{passIds}")
    public AjaxResult remove(@PathVariable Long[] passIds)
    {
        return toAjax(flowPassService.deleteFlowPassByPassIds(passIds));
    }
}
